/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package swa.e_store.businessLogic;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.swing.JOptionPane;
import swa.e_store.entity.Stock;

/**
 *
 * @author Stefan
 */
public class BL_Alert {

    public void raiseMinStockAlert(Stock tmpStockItem) {
        String msg = "Article Nbr: " + tmpStockItem.getArtNbr()
                + "\n is at StockQuantity: " + tmpStockItem.getQuantity()
                + " !! \n Please reorder!\n\n\n ... Message to ShopManager sent.";

        JOptionPane.showMessageDialog(null, msg,
                "LOW STOCK WARNING!" + tmpStockItem.getArtNbr(),
                JOptionPane.ERROR_MESSAGE);
        
        sendMsgToMessageBox(msg);
    }

    public void sendMsgToMessageBox(String msg){

        String file = "MSGBox.txt";
        try {
                FileOutputStream fileOutputStr =    new FileOutputStream(file);
                for (int i = 0; i < msg.length(); i++) {
                    fileOutputStr.write((byte) msg.charAt(i));
                }
                fileOutputStr.close();
        }catch (Exception ex) {
            System.out.println(ex);
        }

    }
}

